#include <iostream>
using namespace std;

//食物
class abstractFood
{
public:
	virtual void show() = 0;
};
class Apple :public abstractFood
{
public:
	void show()
	{
		cout << "Apple" << endl;
	}
};
class Orange :public abstractFood
{
public:
	void show()
	{
		cout << "Orange" << endl;
	}
};
class Pork :public abstractFood
{
public:
	void show()
	{
		cout << "Pork" << endl;
	}
};
class Beef :public abstractFood
{
public:
	void show()
	{
		cout << "Beef" << endl;
	}
};

//工厂
class foodFactory
{
public:
	virtual abstractFood* getFood() = 0;
};
class AppleFactory :public foodFactory
{
public:
	abstractFood* getFood()
	{
		eturn new Apple();
	}
};
class OrangeFactory :public foodFactory
{
public:
	abstractFood* getFood()
	{
		eturn new Orange();
	}
};
class PorkFactory :public foodFactory
{
public:
	abstractFood* getFood()
	{
		eturn new Pork();
	}
};
class MeatFactory :public foodFactory
{
public:
	abstractFood* getFood()
	{
		eturn new Meat();
	}
};

int main()
{
	foodFactory* foodFac;
	foodFac = new AppleFactory();

	abstractFood* food;
	food = foodFac->getFood();
	food->show();
	
	food = foodFac->getFood();
	food->show();

	foodFac = new OrangeFactory();
	food = foodFac->getFood();
	food->show();
	food = foodFac->getFood();
	food->show();
}
 //工厂方法的缺陷就是一种工厂只能生产一类产品，如苹果工厂，只能生成各种苹果。
 //但如果现在有中国苹果和外国苹果，我们生产时，就不能让美国工厂生产中国苹果。